package com.apes.scm.masterdata.car.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 功能：车型
 *
 * @Auther: linwz
 * @Date: 2018/7/19 17:57
 */

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = CarModel.CONST_TABLE_NAME)
public class CarModel extends Model {

    public static final String CONST_TABLE_NAME = "mas_car_model";

    @Id
    @Column(name = "id", length = 8)
    @Comment("车型编码")
    private String id;//车型编码

    @Name
    @Column(name = "name",length = 120,nullable = false)
    @Comment("车型名称")
    private String name;//车型名称

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "car_label_id", referencedColumnName = "id",nullable = false)
    @Comment("厂牌")
    private CarLabel carLabel;//厂牌

}
